(function(c) {
  c(CodeMirror);
})(function(c) {
  var b = /MSIE \d/.test(navigator.userAgent) && (document.documentMode == null || document.documentMode < 8), o = c.Pos, x = { "(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<" };
  function L(t) {
    return t && t.bracketRegex || /[(){}[\]]/;
  }
  function p(t, a, e) {
    var s = t.getLineHandle(a.line), r = a.ch - 1, l = e && e.afterCursor;
    l == null && (l = /(^| )cm-fat-cursor($| )/.test(t.getWrapperElement().className));
    var h = L(e), u = !l && r >= 0 && h.test(s.text.charAt(r)) && x[s.text.charAt(r)] || h.test(s.text.charAt(r + 1)) && x[s.text.charAt(++r)];
    if (!u)
      return null;
    var n = u.charAt(1) == ">" ? 1 : -1;
    if (e && e.strict && n > 0 != (r == a.ch))
      return null;
    var g = t.getTokenTypeAt(o(a.line, r + 1)), i = y(t, o(a.line, r + (n > 0 ? 1 : 0)), n, g, e);
    return i == null ? null : {
      from: o(a.line, r),
      to: i && i.pos,
      match: i && i.ch == u.charAt(0),
      forward: n > 0
    };
  }
  function y(t, a, e, s, r) {
    for (var l = r && r.maxScanLineLength || 1e4, h = r && r.maxScanLines || 1e3, u = [], n = L(r), g = e > 0 ? Math.min(a.line + h, t.lastLine() + 1) : Math.max(t.firstLine() - 1, a.line - h), i = a.line; i != g; i += e) {
      var f = t.getLine(i);
      if (f) {
        var k = e > 0 ? 0 : f.length - 1, M = e > 0 ? f.length : -1;
        if (!(f.length > l))
          for (i == a.line && (k = a.ch - (e < 0 ? 1 : 0)); k != M; k += e) {
            var B = f.charAt(k);
            if (n.test(B) && (s === void 0 || (t.getTokenTypeAt(o(i, k + 1)) || "") == (s || ""))) {
              var H = x[B];
              if (H && H.charAt(1) == ">" == e > 0)
                u.push(B);
              else if (u.length)
                u.pop();
              else
                return { pos: o(i, k), ch: B };
            }
          }
      }
    }
    return i - e == (e > 0 ? t.lastLine() : t.firstLine()) ? !1 : null;
  }
  function A(t, a, e) {
    for (var s = t.state.matchBrackets.maxHighlightLineLength || 1e3, r = e && e.highlightNonMatching, l = [], h = t.listSelections(), u = 0; u < h.length; u++) {
      var n = h[u].empty() && p(t, h[u].head, e);
      if (n && (n.match || r !== !1) && t.getLine(n.from.line).length <= s) {
        var g = n.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
        l.push(t.markText(n.from, o(n.from.line, n.from.ch + 1), { className: g })), n.to && t.getLine(n.to.line).length <= s && l.push(t.markText(n.to, o(n.to.line, n.to.ch + 1), { className: g }));
      }
    }
    if (l.length) {
      b && t.state.focused && t.focus();
      var i = function() {
        t.operation(function() {
          for (var f = 0; f < l.length; f++)
            l[f].clear();
        });
      };
      if (a)
        setTimeout(i, 800);
      else
        return i;
    }
  }
  function v(t) {
    t.operation(function() {
      t.state.matchBrackets.currentlyHighlighted && (t.state.matchBrackets.currentlyHighlighted(), t.state.matchBrackets.currentlyHighlighted = null), t.state.matchBrackets.currentlyHighlighted = A(t, !1, t.state.matchBrackets);
    });
  }
  function d(t) {
    t.state.matchBrackets && t.state.matchBrackets.currentlyHighlighted && (t.state.matchBrackets.currentlyHighlighted(), t.state.matchBrackets.currentlyHighlighted = null);
  }
  c.defineOption("matchBrackets", !1, function(t, a, e) {
    e && e != c.Init && (t.off("cursorActivity", v), t.off("focus", v), t.off("blur", d), d(t)), a && (t.state.matchBrackets = typeof a == "object" ? a : {}, t.on("cursorActivity", v), t.on("focus", v), t.on("blur", d));
  }), c.defineExtension("matchBrackets", function() {
    A(this, !0);
  }), c.defineExtension("findMatchingBracket", function(t, a, e) {
    return (e || typeof a == "boolean") && (e ? (e.strict = a, a = e) : a = a ? { strict: !0 } : null), p(this, t, a);
  }), c.defineExtension("scanForBracket", function(t, a, e, s) {
    return y(this, t, a, e, s);
  });
});
